<template>
	<view class="main">
		<view class="mains">
			<u-sticky>
				<view class="search">
					<u-search placeholder="名称" v-model="keyword" bgColor="#ffffff" :showAction="false"></u-search>
				</view>
			</u-sticky>
			<view class="lists">
				<view class="item" v-for="index in 4" :key="index">
					<view class="up">
						<view class="lefts">
							<text class="name">名称</text>
							<text>活动名称：24版钱宝电银产权机流量费0-68</text>
							<text>活动编号：1112255895685665</text>
							<text class="state">正常</text>
						</view>
						<view class="rights">
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="down">
						<view class="lefts" @click="snInstall(index, 2)">
							批量装机
						</view>
						<view class="rights" @click="snInstall(index, 1)">
							扫一扫装机
						</view>
					</view>
				</view>
			</view>
			<view class="bottom">
				<view class="query">
					模板查询
				</view>
				<view class="add" @click="add">
					新增
				</view>
			</view>
			<u-overlay :show="show">
				<view class="tc_box">
					<view class="tc_title">{{tc_title}}</view>
					<view class="tc_content">
						<view class="item">
							<view v-if="sn_type==1" class="top">
								<view class="one_sn">
									<view class="lefts">
										<text>机具编号</text>
									</view>
									<view class="rights">
										<text>机具编号</text>
										<u-icon name="scan" size="20"></u-icon>
									</view>
								</view>
								<view class="msg">
									<u-icon name="error-circle-fill" size="20" color="#F56C6C"></u-icon>
									<text>请优先使用摄像头扫极具背面SN号</text>
								</view>
							</view>
							<view v-else class="top">
								<view class="batch_sn">
									<input type="text" placeholder="起始SN号" v-model="formData.start_sn">
								</view>
								<view class="batch_line">
									<text>|</text>
								</view>
								<view class="batch_sn">
									<input type="text" placeholder="结束SN号" v-model="formData.end_sn">
								</view>
							</view>
							<view class="bottoms">
								<view class="lefts">
									<text>装机品牌</text>
								</view>
								<view class="rights" @click="brandShow = true">
									<text>{{brandName}}</text>
									<u-icon name="arrow-right"></u-icon>
								</view>
							</view>
						</view>
					</view>
					<view class="tc_bottom">
						<view class="lefts" @click="show = false">
							<text>取消</text>
						</view>
						<view class="rights" @click="tcSelect">
							<text>确定</text>
						</view>
					</view>
					<u-picker :show="brandShow" :columns="brandData" keyName="label" @confirm="brandSelect" @cancel="brandShow = false"></u-picker>
				</view>
			</u-overlay>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword: '',
				show: false,
				brandShow: false,
				tc_title: '批量装机',
				sn_type: 1,
				brandData: [[{
					id: 1,
					label: '合利宝'
				},{
					id: 2,
					label: '钱宝'
				},{
					id: 3,
					label: '畅捷'
				},{
					id: 4,
					label: '中付'
				}]],
				brandName: '请选择',
				brandId: null,
				formData: {
					start_sn: '',
					end_sn: ''
				}
			}
		},
		methods: {
			add() {
				uni.navigateTo({
					url: '/pages/index/installtmp/add'
				})
			},
			snInstall(item, type) {
				this.sn_type = type
				this.show = true
			},
			scanInstall(index) {
				this.show = true
			},
			batchInstall(index) {
				this.show = true
			},
			tcSelect() {
				
			},
			brandSelect(e) {
				this.brandId = e.value[0].id
				this.brandName = e.value[0].label
				this.brandShow = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F2F6FC;
	}
	.mains {
		.search {
			padding: 30rpx;
			background-color: #F2F6FC;
		}
		
		.lists {
			padding: 0 30rpx;
			padding-bottom: 130rpx;
			.item {
				margin-bottom: 30rpx;
				background-color: #ffffff;
				border-radius: 20rpx;
				box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
				
				.up {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 20rpx;
					border-bottom: 1px solid #DCDFE6;
					
					text {
						display: block;
						font-size: 24rpx;
					}
					
					.name {
						font-size: 28rpx;
						font-weight: bold;
						padding-bottom: 10rpx;
					}
					
					.state {
						display: inline;
						background-color: #409EFF;
						color: #ffffff;
						padding: 4rpx 20rpx;
						border-radius: 10rpx;
					}
				}
				.down {
					display: flex;
					color: #409EFF;
					text-align: center;
					.lefts {
						padding: 20rpx 0;
						width: 50%;
						border-right: 1px solid #DCDFE6;
					}
					.rights {
						padding: 20rpx 0;
						width: 50%;
					}
				}
			}
		}
		
		.bottom {
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			background-color: #ffffff;
			text-align: center;
			padding: 20rpx;
			display: flex;
			justify-content: space-around;
			.query {
				width: 48%;
				background-color: #E6A23C;
				color: #ffffff;
				border-radius: 20rpx;
				padding: 20rpx 0;
			}
			.add {
				width: 48%;
				background-color: #409EFF;
				color: #ffffff;
				border-radius: 20rpx;
				padding: 20rpx 0;
			}
		}
	
		.tc_box {
			width: 90%;
			margin: auto auto;
			background-color: #ffffff;
			border-radius: 20rpx;
			font-size: 28rpx;
			.tc_title {
				padding: 30rpx 0;
				font-weight: bold;
				text-align: center;
				border-bottom: 1px solid #DCDFE6;
			}
			
			.tc_content {
				padding: 20rpx;
				.item {
					padding-bottom: 30rpx;
					.top {
						padding-bottom: 30rpx;
						
						.one_sn {
							padding: 30rpx;
							display: flex;
							justify-content: space-between;
							align-items: center;
							border-bottom: 1px solid #DCDFE6;
							.rights {
								display: flex;
								justify-content: flex-end;
								text {
									padding-right: 20rpx;
									color: #909399;
								}
							}
						}
						
						.msg {
							padding: 20rpx 30rpx;
							display: flex;
							justify-content: flex-start;
							align-items: center;
							text {
								padding-left: 10rpx;
								color: #909399;
							}
						}
						
						.batch_sn {
							padding: 0 30rpx;
							text-align: center;
							input {
								background-color: #DCDFE6;
								border-radius: 10rpx;
								padding: 20rpx;
							}
						}
						.batch_line {
							text-align: center;
							padding-bottom: 10rpx;
						}
					}
					.bottoms {
						padding: 20rpx 0;
						display: flex;
						justify-content: space-between;
						border-top: 1px solid #DCDFE6;
						
						.rights {
							display: flex;
							text {
								color: #909399;
								padding-right: 10rpx;
							}
						}
					}
				}
			}
			
			.tc_bottom {
				display: flex;
				justify-content: space-between;
				border-top: 1px solid #DCDFE6;
				.lefts {
					padding: 20rpx 0;
					width: 50%;
					text-align: center;
					border-right: 1px solid #DCDFE6;
				}
				.rights {
					width: 50%;
					padding: 20rpx 0;
					text-align: center;
					color: #409EFF;
				}
			}
		}
	}
</style>
